package com.wwj.core.wawa.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.wwj.core.wawa.entity.Item;
import com.wwj.core.wawa.entity.mapper.ItemMapper;
import com.wwj.core.wawa.service.IItemService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * Created by Administrator on 2017/11/3.
 */
@Service
public class ItemServiceImpl implements IItemService {

    @Resource
    private ItemMapper itemMapper;

    @Override
    public List<Item> findByType(int type) {
        return itemMapper.selectItemsByType(type);
    }

    @Override
    public Page<Item> findByPage(int offset, int limit, Map<String, Object> params) {
        PageHelper.offsetPage(offset, limit);
        return (Page<Item>)itemMapper.selectItems(params);
    }

    @Override
    public void addItem(Item item) {
        itemMapper.insertItem(item);
    }

    @Override
    public void modifyItem(Item item) {
        itemMapper.updateItem(item);
    }

    @Override
    public Item findById(Integer id) {
        return itemMapper.selectItemById(id);
    }

    @Override
    public void deleteById(Integer id) {
        itemMapper.deleteItemById(id);
    }
}
